// pages/input/input.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    title: ['Pol β', 'APE1', 'UNG', 'PRKDC', 'PARP1', 'MNAT1', 'FEN1', 'RAD51', 'PCNA', 'KU80', 'CD70', 'CD19', 'BCMA', 'CD30', 'CD22'],
    resdata: [],
    res: [ //flag: 0小于，1大于
      {
        name: 'ACC肾上腺皮脂癌',
        tpm: [0, 100, 60, 0, 0, 0, 11, 0, 68, 52, 0, 0, 0, 0, 0],
        flag: [0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0]
      },
      {
        name: 'BLCA膀胱尿路上皮癌',
        tpm: [0, 0, 30, 60, 0, 0, 28, 7, 120, 0, 0, 0, 0, 0, 0],
        flag: [0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0]
      },
      {
        name: 'BRCA乳腺癌',
        tpm: [30, 0, 30, 60, 0, 0, 20, 5, 100, 0, 0, 0, 0, 0, 0],
        flag: [1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0]
      },
      {
        name: 'CESC宫颈癌',
        tpm: [0, 0, 40, 0, 0, 0, 40, 10, 0, 0, 0, 0, 0, 0, 0],
        flag: [0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0]
      },
      {
        name: 'CHOL胆管癌',
        tpm: [0, 120, 0, 32, 300, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0],
        flag: [0, 1, 0, 1, 0, 0, 1]
      },
      {
        name: 'COAD结直肠癌',
        tpm: [0, 0, 40, 65, 0, 0, 25, 10, 140, 0, 0, 0, 0, 0, 0],
        flag: [0, 0, 1, 1, 0, 0, 1, 1, 1]
      },
      {
        name: 'DLBC弥漫大B细胞淋巴瘤',
        tpm: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 40, 20, 0, 60],
        flag: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1]
      },
      {
        name: 'ESCA食道癌',
        tpm: [0, 0, 0, 70, 0, 0, 23, 8, 130, 128, 0, 0, 0, 0, 0],
        flag: [0, 0, 0, 1, 0, 0, 1, 1, 1, 1]
      },
      {
        name: 'GBM多形性胶质母细胞瘤',
        tpm: [0, 150, 0, 0, 0, 0, 20, 5, 100, 100, 0, 0, 0, 0, 0],
        flag: [0, 1, 0, 0, 0, 0, 1, 1, 1, 1]
      },
      {
        name: 'HNSC头颈鳞状细胞癌',
        tpm: [0, 110, 0, 70, 0, 0, 30, 10, 130, 0, 0, 0, 0, 0, 0],
        flag: [0, 1, 0, 1, 0, 0, 1, 1, 1]
      },
      {
        name: 'KICH肾嫌色细胞癌',
        tpm: [14, 65, 0, 0, 10, 19, 0, 0, 0, 42, 0, 0, 0, 0, 0],
        flag: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0]
      },
      {
        name: 'KIRC肾透明细胞癌',
        tpm: [0, 110, 0, 0, 30, 16, 7, 0, 0, 0, 20, 0, 0, 0, 0],
        flag: [0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1]
      },
      {
        name: 'KIRP肾乳头状细胞癌',
        tpm: [0, 0, 27, 0, 30, 0, 6.5, 0, 50, 80, 0, 0, 0, 0, 0],
        flag: [0, 0, 1, 0, 0, 0, 1, 0, 1, 1]
      },
      {
        name: 'LAML急性髓系白血病',
        tpm: [0, 200, 80, 0, 30, 30, 20, 0, 0, 0, 0, 0, 0, 0],
        flag: [0, 1, 0, 1, 0, 0, 1, 0, 1, 1]
      },
      {
        name: 'LGG脑低级别胶质瘤',
        tpm: [0, 150, 0, 50, 0, 0, 15, 0, 45, 80, 0, 0, 0, 0, 0],
        flag: [0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0]
      },
      {
        name: 'LIHC肝细胞癌',
        tpm: [0, 0, 16, 20, 500, 0, 10, 0, 40, 0, 0, 0, 0, 0, 0],
        flag: [0, 0, 1, 1, 1, 0, 1, 0, 1]
      },
      {
        name: 'LUAD肺腺癌',
        tpm: [26, 0, 20, 0, 0, 0, 15, 4, 65, 0, 0, 0, 0, 0, 0],
        flag: [1, 0, 1, 0, 0, 0, 1, 1, 1]
      },
      {
        name: 'LUSC肺鳞状细胞癌',
        tpm: [0, 0, 30, 80, 0, 0, 25, 10, 140, 0, 0, 0, 0, 0, 0],
        flag: [0, 0, 1, 1, 0, 0, 1, 1, 1]
      },
      {
        name: 'OV卵巢浆液性囊腺癌',
        tpm: [0, 200, 26, 0, 0, 0, 12, 6, 88, 0, 0, 0, 0, 0, 40],
        flag: [0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0]
      },
      {
        name: 'PAAD胰腺癌',
        tpm: [20, 0, 12, 0, 8, 15, 10, 0, 50, 0, 0, 0, 0, 0, 0],
        flag: [1, 0, 1, 0, 1, 1, 1, 0, 1]
      },
      {
        name: 'PCPG嗜铬细胞瘤和副神经节瘤',
        tpm: [25, 0, 20, 30, 0, 0, 11, 0, 0, 80, 0, 0, 0, 0, 0],
        flag: [1, 0, 0, 1, 0, 0, 0, 0, 0, 1]
      },
      {
        name: 'PRAD前列腺癌',
        tpm: [38, 130, 30, 0, 0, 0, 8, 0, 40, 0, 0, 0, 0, 0, 0],
        flag: [1, 1, 1, 0, 0, 0, 1, 0, 1]
      },
      {
        name: 'READ直肠癌',
        tpm: [20, 0, 35, 0, 100, 0, 20, 10, 50, 0, 0, 0, 0, 0, 0],
        flag: [1, 0, 1, 0, 1, 0, 1, 1, 1]
      },
      {
        name: 'SARC肉瘤',
        tpm: [0, 0, 0, 60, 10, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0],
        flag: [0, 0, 0, 1, 0, 0, 0, 1]
      },
      {
        name: 'SKCM皮肤黑色素瘤',
        tpm: [32, 0, 0, 60, 0, 0, 27, 7, 120, 0, 0, 0, 0, 0, 0],
        flag: [1, 0, 0, 1, 0, 0, 1, 1, 1]
      },
      {
        name: 'STAD胃癌',
        tpm: [0, 0, 0, 25, 20, 0, 16, 7, 100, 0, 0, 0, 0, 0, 0],
        flag: [0, 0, 0, 1, 1, 0, 1, 1, 1]
      },
      {
        name: 'TGCT睾丸生殖细胞瘤',
        tpm: [0, 100, 80, 0, 10, 0, 0, 0, 110, 200, 0, 0, 0, 0, 0],
        flag: [0, 1, 1, 0, 0, 0, 0, 0, 1, 1]
      },
      {
        name: 'THCA甲状腺癌',
        tpm: [5, 120, 0, 0, 0, 0, 5, 0, 50, 110, 0, 0, 0, 0, 0],
        flag: [1, 1, 0, 0, 0, 0, 1, 0, 1, 1]
      },
      {
        name: 'THYM胸腺癌',
        tpm: [15, 100, 10, 40, 0, 20, 15, 7, 100, 0, 0, 0, 0, 0, 0],
        flag: [1, 1, 1, 1, 0, 1, 1, 1, 1]
      },
      {
        name: 'UCEC子宫体子宫内膜癌',
        tpm: [0, 180, 30, 0, 0, 0, 28, 7, 100, 0, 0, 0, 0, 0, 0],
        flag: [0, 1, 1, 0, 0, 0, 1, 1, 1]
      },
      {
        name: 'UCS子宫癌肉瘤',
        tpm: [35, 0, 26, 0, 0, 0, 20, 6, 95, 0, 0, 0, 0, 0, 0],
        flag: [1, 0, 1, 0, 0, 0, 1, 1, 1]
      }
    ]
  },

  initarr(arr) {
    for (let i = 0; i < 15; i++) {
      arr[i] = true
    }
  },
  check() {
    let res = false
    let restitle = []
    let arr = []
    for (let i = 0; i < this.data.res.length; i++) {
      this.initarr(arr)
      for (let j = 0; j < 15; j++) {
        if (this.data.res[i].tpm[j] === 0) {
          arr[j] = false
          continue
        } else {
          if (this.data.res[i].flag[j] === 0) { //如果小于
            if (this.data.resdata[j] < this.data.res[i].tpm[j]) {
              arr[j] = false
              //restitle.push(this.data.res[i].name)
            }
          } else { //如果大于
            if (this.data.resdata[j] > this.data.res[i].tpm[j]) {
              arr[j] = false
              //restitle.push(this.data.res[i].name)
            }
          }
        }
      }
      if (arr.every(e => {  //判断arr是否都为false
        return e === false
      })) {
        restitle.push(this.data.res[i].name)
      }
    }
    return restitle
  },
  input(e) {
    let i = e.currentTarget.dataset.i
    let t = e.detail.value * 1
    let arr = this.data.resdata
    arr[i] = t
    this.setData({
      resdata: arr
    })
  },
  submit() {
    let arr = this.check()
    let flag = arr.length === 0 ? '无几率' : '有几率'
    let res = arr.length === 0
    console.log(flag + ' || ' + arr + '||' + res);
    wx.navigateTo({
      url: `../resault/resault?flag=${ res }&arr=${ arr }`,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let tmp = []
    for (let i = 0; i < 15; i++) {
      tmp.push(0)
    }
    this.setData({
      resdata: tmp
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})